﻿using System;
using SharePoint.Contrib.InversionOfControl;

namespace SharePoint.Contrib.Extensions
{
    /// <summary>
    /// Extensions for the Exception class
    /// </summary>
    public static class ExceptionExtensions
    {
        /// <summary>
        /// Writes the exception details to the SharePoint ULS and Windows Event Log using the specified area and category.
        /// </summary>
        /// <param name="area">the area name</param>
        /// <param name="category">the category name</param>
        public static void HandleException(this Exception instance, string area, string category)
        {
            SPCServiceLocator.Current
                .DiagnosticsService
                .HandleException(area, category, instance);
        }
    }
}
